<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta
    name="viewport"
    content="width=device-width, initial-scale=1.0"
  >
  <title>chatRoom</title>
</head>

<body>
  <button id="sendBtn">test</button>

  <script src="../node_modules/socket.io/client-dist/socket.io.js"></script>
  <script src="../node_modules/axios/dist/axios.js"></script>
  <script>
    // var socket = io.connect(),
    var button = document.getElementById('sendBtn');
    button.onclick = function () {
      console.log(this)
      // socket.emit('foo', 'hello');
    }
    axios.defaults.baseURL = 'http://192.168.0.113:8000';
    axios.defaults.withCredentials = true;
    axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded';
    axios.defaults.transformRequest = function (data) {
      if (!data) return;
      let result = "";
      for (let attr in data) {
        if (!data.hasOwnProperty(attr)) break;
        result += `&${attr}=${data[attr]}`;
      }
      return result.substring(1);
    }
    axios.interceptors.response.use(function onFulfilled(response) {
      return response.data;
    }, function onReject(reason) {
      return Promise.reject(reason);
    });
    axios.defaults.validateStatus = function (status) {
      return /^(2|3)\d{2}$/.test(status);
    }
    axios.get('http://192.168.0.113:8000')
      .then(result => {
        console.log(result)
      })
  </script>
</body>

</html>